home *** CD-ROM | disk | FTP | other *** search
Wrap
/* Done by Allan 'Duff' Odgaard on Friday 11-Nov-94 22:18:34 For selective extraction of Lh-Archives in DirectoryOpus. Features: Fast list reading, then double click to: MultiView, Delete, Execute... or just click-m-click to: Extract with path (Y/N), Extract as... Dir creation is possible just by using '/' in 'Extract As' output name. ReqTools are used for easy selection, Spaces in every file name is possible, and multiple files can be selected. It's also possible to extract/delete/multiview on files containing wildcards If you execute a file with eg. CygnusEd as command, and you save it. You'll be asked to update file to archive! »»» NO ALTERNATIVES! ««« $VER: LhA-Control.Rexx V2.4 (11-Nov-94) Allan 'Duff' Odgaard */ Address DOPUS.1 Trace Results Parse Arg '"' SourceArc '"' PortName . If PortName ~= '' Then Address(PortName) Options Results Options FailAt 21 Query ScreenName PubScreen = Result /* The next FIVE (5) lines may be modified in a controlled way! */ Rx = 'Sys:RexxC/Rx' LhA = 'LhA' Shell = 'Con:000/026/724/244/LhA-Selector V2.4 Output/Screen ' || PubScreen MultiView = 'SYS:Utilities/MultiView' TmpPath = 'T:LhA-Control_by_Duff!/' /* ^^ ------------------------------» ONLY change the assign !!! */ /* You're now entering the part of the script, which should stay as it is. */ Signal On Syntax TmpList = TmpPath'TmpLhAList.Duff' TmpFiles = TmpPath'TmpExtFiles.Duff' ScriptFile = TmpPath'TmpScript.Duff' lf = '0a'x Status 3 ActiveWin = Result Status 13 ActiveWin CurrentPath = Result If Show('p','MouseActions') = 1 Then Call AllReady Call AddLib("rexxsupport.library",0,-30,0) Call AddLib("rexxreqtools.library",0,-30,0) If SourceArc ~= '' Then Signal GotIt GetNextSelected SourceArc = Result If SourceArc = 0 Then Signal Fuser GotIt: If Open('TestForLhA',CurrentPath || SourceArc,'R') = 0 Then Signal NotALhAFile Seek('TestForLhA',2,'B') If ReadCh('TestForLhA',3) ~= '-lh' Then Signal NotALhAFile Close('TestForLhA') Status 21 ActiveWin set 1 ClearWin TopText 'Listing 'SourceArc' to buffer...' Busy On Address Command 'C:MakeDir "'Left(TmpPath,Length(TmpPath)-1)'"' Address Command 'C:Assign "Used By Duff:" "'Left(TmpPath,Length(TmpPath)-1)'"' Address Command LhA' vq -INMQw "'CurrentPath || SourceArc'" >"'TmpList'"' Address Command 'C:Sort "'TmpList'" "'TmpList'"' Open('Archive',TmpList,'R') SetWinTitle '"'SourceArc':"' ActiveWin AddCustEntry '" -> Double click me when finished <- "' 0 '2' '3' '1' '0' '-1' FindLoop: Entry = ReadLn('Archive') If EOF('Archive') Then Signal FoundAll AddCustEntry '"'Entry'"' '?' '-1' '-1' '1' '0' '-1' Signal FindLoop FoundAll: Close('Archive') Delete(TmpList) DisplayDir AddCustHandler 'MouseActions' ActiveWin OpenPort('MouseActions') Busy Off WaitForSignal: TopText "Place your order or Exit me now !!" Call WaitPkt('MouseActions') Packet = GetPKT('MouseActions') Click = GetArg(packet,0) Number = GetArg(packet,1) Name = GetArg(packet,2) User = GetArg(packet,3) Reply(packet,0) Busy On If Click=1 Then If Number=0 Then Signal End Else Signal DoActionOnFile If Click=2 Then If Number=0 Then Signal SecretPart Else Signal AddEntry2File If Click=q Then Signal End Busy Off Signal WaitForSignal AddEntry2File: Status 3 set ActiveWin SelectEntry Number 1 1 SelectEntry 0 0 1 Status 3 Set ActiveWin GetSelectedAll AllFiles = Result NumberOfFiles = Words(AllFiles) Busy On Call rtezrequest("There are " || NumberOffiles || " selected file(s)." || lf || lf || "Extract file(s) with full path?", "_Yes|_No|_Extract as...|_Cancel","LhA-Control V2.4","RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Busy Off If RTResult = 0 Then Signal WaitForSignal Busy On If RTResult = 3 Then Signal ExtractAs TopText 'Building list over file(s) to extract...' Open('Selected',TmpFiles,'W') Do Subject = 1 to NumberOfFiles SelectEntry Word(AllFiles,Subject) 0 1 GetEntry Word(AllFiles,Subject)+1 WriteLn('Selected','"'WildCard(Result)'"') End Subject Extract: Close('Selected') TopText 'Extracting selected file(s)...' Status 13 1-ActiveWin Path = Result If RTResult = 1 Then Address Command LhA' x -a -qIM -Qw "'CurrentPath || SourceArc'" "@'TmpFiles'" "'Path'"' Else Address Command LhA' e -a -qIM -x2 -Qw "'CurrentPath || SourceArc'" "@'TmpFiles'" "'Path'"' Delete(TmpFiles) ReScan 1-ActiveWin Busy Off Signal WaitForSignal ExtractAs: TopText "Extracting and renaming file(s)..." Busy On Subject=0 GoLoop: Busy On SelectEntry Word(AllFiles,Subject+1) 0 1 GetEntry Word(AllFiles,Subject+1)+1 Name = Result TstName = Substr(Name,LastPos("/",Name)+1) Status 13 1-ActiveWin Path = Result Call rtgetstring(Name,"(Use '/' in name for dir creation.)" || lf lf || "Enter New File Name:","LhA-Control V2.4","_Extract|_Skip","RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Altered = Result If RTResult = 0 Then Signal FuncCanceled Busy On If Exists(Path || Altered) = 1 Then Address Command 'C:Delete "'Path || WildCard(Altered)'"' Call MakeNeededDir Altered If Exists(Path || TstName) = 0 Then Do Address Command LhA' e -a -qIM -x2 -Qw "'CurrentPath || SourceArc'" "'WildCard(Name)'" "'Path'"' Address Command 'C:Rename "'Path || WildCard(TstName)'" To "'Path || Altered'"' End Else Do Address Command LhA' e -a -qIM -x2 -Qw "'CurrentPath || SourceArc'" "'WildCard(Name)'" "'TmpPath'"' If Altered = WildCard(Altered) Then Do Address Command 'C:Copy "'TmpPath || WildCard(TstName)'" To "'Path || Altered'"' Address Command 'C:Delete "'TmpPath || WildCard(TstName)'"' End Else Do Address Command 'C:Rename "'TmpPath || WildCard(TstName)'" To "'TmpPath'^Findes ik^"' Address Command 'C:Copy "'TmpPath'^Findes ik^" To "'Path'^Findes ik^"' Address Command 'C:Rename "'Path'^Findes ik^" To "'Path || Altered'"' Address Command 'C:Delete "'TmpPath'^Findes ik^"' Address Command 'C:Delete "'TmpPath || WildCard(TstName)'"' End End ReScan 1-ActiveWin FuncCanceled: Subject = Subject +1 if Subject ~= NumberOfFiles Then Signal GoLoop Busy Off Signal WaitForSignal MakeNeededDir: Parse Arg SinglePath NewPos = 0 CreatePath: If Verify(Substr(SinglePath,NewPos+1),'/','Match') = 0 Then Signal Go NewPos = Verify(Substr(SinglePath,NewPos+1),'/','Match') + NewPos MakeDir(Path || Left(SinglePath,NewPos-1)) Signal CreatePath Go: Return DoActionOnFile: SelectEntry Number 1 1 SelectEntry 0 0 1 Status 3 Set ActiveWin GetSelectedAll AllFiles = Result NumberOfFiles = Words(AllFiles) Busy On If Right(Name,5) = '.info' Then Call rtezrequest("There are " || NumberOffiles || " selected file(s)." || lf || lf || "Perform wich kind of action on file(s)?", "_MultiView|_Delete|_Execute...|_IconInfo|_Cancel","LhA-Control V2.4","RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Else Call rtezrequest("There are " || NumberOffiles || " selected file(s)." || lf || lf || "Perform wich kind of action on file(s)?", "_MultiView|_Delete|_Execute...|_Cancel","LhA-Control V2.4","RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Busy Off If RTResult = 1 Then Signal MultiView If RTResult = 2 Then Signal DeleteFile If RTResult = 3 Then Signal Execute If RTResult = 4 Then Signal IconInfo If RTResult = 0 Then Signal WaitForSignal EndAction: Signal WaitForSignal MultiView: TopText "Extracting and MultiView'ing file(s)..." Busy On Subject=1 AIDW: SelectEntry Word(AllFiles,Subject) 0 1 GetEntry Word(AllFiles,Subject)+1 Name = Result TstName = Substr(Name,LastPos("/",Name)+1) Address Command LhA' e -a -qIM -x2 -Qw "'CurrentPath || SourceArc'" "'WildCard(Name)'" "'TmpPath'"' Address Command MultiView' "'TmpPath || TstName'" Screen' Address Command 'C:Delete "'TmpPath || WildCard(TstName)'"' Subject = Subject + 1 If Subject ~= NumberOfFiles+1 Then Signal AIDW DOpusToFront Busy Off Signal WaitForSignal DeleteFile: TopText "Deleting selected file(s) in archive..." Busy On Open('Selected',TmpFiles,'W') Do Subject = 1 to NumberOfFiles SelectEntry Word(AllFiles,Subject)-(Subject-1) 0 1 GetEntry Word(AllFiles,Subject)+1-(Subject-1) WriteLn('Selected','"'WildCard(Result)'"') RemoveEntry Word(AllFiles,Subject)-(Subject-1) 1 End Subject Close('Selected') Address Command LhA' d -qIM -Qp -Qw "'CurrentPath || SourceArc'" "@'TmpFiles'"' Delete(TmpFiles) ClearWin AddCustHandler 'MouseActions' ActiveWin OpenPort('MouseActions') TopText 'Re-reading 'SourceArc' to buffer...' Address Command LhA' vq -INM -Qw "'CurrentPath || SourceArc'" >"'TmpList'"' Open('Archive',TmpList,'R') SetWinTitle '"'SourceArc':"' ActiveWin AddCustEntry '" -> Double click me when finished <- "' 0 '2' '3' '1' '0' '-1' FindLoop2: Entry = ReadLn('Archive') If EOF('Archive') Then Signal FoundAll2 AddCustEntry '"'Entry'"' '?' '-1' '-1' '1' '0' '-1' Signal FindLoop2 FoundAll2: Close('Archive') Delete(TmpList) DisplayDir Busy Off Signal WaitForSignal Execute: TopText "Extracting and executing file(s)..." Busy On Subject=1 FuckLoop: SelectEntry Word(AllFiles,Subject) 0 1 GetEntry Word(AllFiles,Subject)+1 Name = Result TstName = Substr(Name,LastPos("/",Name)+1) Call rtgetstring(TstName,"Enter Command and its Arguments:","LhA-Control V2.4","_Execute|_Skip","RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Altered = Result If RTResult = 0 Then Signal NameChanged Busy On Address Command LhA' e -a -qIM -x2 -Qw "'CurrentPath || SourceArc'" "'WildCard(Name)'" "'TmpPath'"' If Pos(TstName,Altered) = 0 Then WholeFile = Altered Else Do First = Left(Altered,Pos(TstName,Altered)-1) Middle = '"'TmpPath || TstName'"' Last = Right(Altered,length(Altered)-(Pos(TstName,Altered)+length(TstName)-1)) WholeFile = First || Middle || Last End Address Command 'C:List >"'TmpPath'Version1.Duff" "'TmpPath || TstName'" NoHead' Message = Rx' " Address ' Message = Message || "'MouseActions' x" Open('Script',ScriptFile,'W') WriteLn('Script','FailAt 999999') WriteLn('Script','Stack 4096') WriteLn('Script',WholeFile) WriteLn('Script','Echo ""') WriteLn('Script','Echo NoLine " Press [RETURN] to continue..."') WriteLn('Script','Set >NIL: Return ?') WriteLn('Script',Message) WriteLn('Script','EndCLI') Close('Script') Address Command 'C:NewShell "'Shell'" From "'ScriptFile'"' Call WaitPkt('MouseActions') Packet = GetPKT('MouseActions') Reply(packet,0) Delete(ScriptFile) Address Command 'C:List >"'TmpPath'Version2.Duff" "'TmpPath || TstName'" NoHead' Open('OldVer',TmpPath'Version1.Duff','R') Open('NewVer',TmpPath'Version2.Duff','R') If ReadLn('OldVer') ~= ReadLn('NewVer') Then Do Call rtezrequest("The file has been changed." || lf || "Would you like to update it?","_Sure!|_Forget it!","LhA-Control V2.4", "RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) If RTResult = 1 Then Call UpDateFile End Else Address Command 'C:Delete "'TmpPath || WildCard(TstName)'" NoReq >NIL:' Close('OldVer') Close('NewVer') Address Command 'C:Delete "'TmpPath || 'Version[1-2].Duff" >NIL:' NameChanged: Subject = Subject + 1 If Subject ~= NumberOfFiles+1 Then Signal FuckLoop DOpusToFront Busy Off Signal WaitForSignal UpDateFile: SinglePath = Name NewPos = 0 ; First = 0 CreatePath2: If Verify(Substr(SinglePath,NewPos+1),'/','Match') = 0 Then Signal Go2 NewPos = Verify(Substr(SinglePath,NewPos+1),'/','Match') + NewPos If Left(SinglePath,NewPos-1) = TstName & First = 0 Then Do First = 1 Address Command 'C:Rename "'TmpPath || TstName'" "'TmpPath || TstName'.1"' TstName = TstName || '.1' End MakeDir(TmpPath || Left(SinglePath,NewPos-1)) Signal CreatePath2 Go2: Address Command 'C:Rename "'TmpPath || TstName'" "'TmpPath || Name'"' ExeUpdate: Address Command LhA' u -rqIM -Qw "'CurrentPath || SourceArc'" "'TmpPath'" "'Name'"' If RC > 0 Then Signal IOErr ExeDelete: If Verify(Name,'/','Match') = 0 Then Address Command 'C:Delete "'TmpPath || WildCard(Name)'" All NoReq >NIL:' Else Do NewPos = Verify(Name,'/','Match') Address Command 'C:Delete "'TmpPath || WildCard(Left(Name,NewPos))'" All NoReq >NIL:' End Return IconInfo: TopText "Extracting and view'ing icon..." TstName = Substr(Name,LastPos("/",Name)+1) Address Command LhA' e -a -qIM -x2 -Qw "'CurrentPath || SourceArc'" "'WildCard(Name)'" "'TmpPath'"' Address Command 'C:List >"'TmpPath'Version1.Duff" "'TmpPath || TstName'" NoHead' IconInfo '"'TmpPath || TstName'"' Address Command 'C:List >"'TmpPath'Version2.Duff" "'TmpPath || TstName'" NoHead' Open('OldVer',TmpPath'Version1.Duff','R') Open('NewVer',TmpPath'Version2.Duff','R') If ReadLn('OldVer') ~= ReadLn('NewVer') Then Do Call rtezrequest("The file has been changed." || lf || "Would you like to update it?","_Sure!|_Forget it!","LhA-Control V2.4", "RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) If RTResult = 1 Then Call UpDateFile End Else Address Command 'C:Delete "'TmpPath || WildCard(TstName)'" NoReq >NIL:' Close('OldVer') Close('NewVer') Address Command 'C:Delete "'TmpPath || 'Version[1-2].Duff" >NIL:' SelectEntry Number 0 1 Signal WaitForSignal IOErr: Call rtezrequest("Error while updating archive.","_Then try again|_Ohh, fuck that!","LhA-Control V2.4", "RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) If RTResult = 1 Then Signal ExeUpdate Signal ExeDelete Wildcard: Parse Arg NoWild NewPos = 0 SortWild: If Verify(Substr(NoWild,NewPos+1),'~*#?(|)[%]','Match') = 0 Then Signal FindAtr NewPos = Verify(Substr(NoWild,NewPos+1),'~*#?(|)[%]','Match') + NewPos NoWild = Insert("'",NoWild,NewPos-1) NewPos = NewPos + 1 Signal SortWild FindAtr: If left(NoWild,1) = '@' Then NoWild = Insert('*',NoWild,0) Return NoWild End: Status 21 ActiveWin set 9 Address Command 'C:Assign "Used By Duff:" Remove' Address Command 'C:Delete "'Left(TmpPath,Length(TmpPath)-1)'" All NoReq >NIL:' Busy Off Exit Fuser: Call rtezrequest("No file have been selected.","I see","LhA-Control V2.4", "RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Exit NotALhAFile: Call rtezrequest("Sorry, but this doesn't seem to be a LhA file.","hmmrf","LhA-Control V2.4", "RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Exit AllReady: Call rtezrequest("Sorry, but LhA-Control can't be runned twice!" || lf || "Should I quit the other LhA-Ctrl.","_Quit other|_No, commit suicide","LhA-Control V2.4", "RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) If RTResult = 0 Then Exit Else Address 'MouseActions' q BeSure: Address Command 'C:Wait 1' If Show('p','MouseActions') = 0 Then Return Signal BeSure Return BackToBase SecretPart: Busy On Call rtezrequest("LhA-Control V2.4 is © 11-Nov-94 by D&D Productions." lf lf "This is only the demo version of this fabulous ARexx script," lf "to achieve the real version send me:" lf lf "Bug reports, own productions, suggestions or gift's!" lf "(Don't forget to include a disk)" lf "It should be sent to:" lf "Allan 'Duff' Odgaard" lf "Classensgade 25A, 1th," lf "DK-2100 Copenhagen," lf "Denmark." lf lf "Bye the way, I love Asm-One V100 by Detron!!!","I'll do that!","You found the secret about window!!!","RTEz_Flags=EZReqF_CenterText RT_ReqPos=ReqPos_CenterScr RT_PubScrName="PubScreen) Busy Off Status 3 set ActiveWin SelectEntry 0 0 1 Signal WaitForSignal Syntax: Beep Status 21 ActiveWin set 9 Address Command 'C:Assign "Used By Duff:" Remove' Address Command 'C:Delete "'Left(TmpPath,Length(TmpPath)-1)'" All NoReq' Busy Off TopText "Syntax Error" rc"," errortext(rc) "in line" sigl"." Exit